package com.hqyj.springbootday03.modules.test.dao;

import com.hqyj.springbootday03.modules.test.entity.Student;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StudentDao extends JpaRepository<Student,Integer> {

    List<Student> findByStudentName(String studentName);

    @Modifying
    //对象:#{#xxx.xxx}
//	@Query(nativeQuery = true, value = "update test_student set student_name = :#{#student.studentName} " +
//			"where id = :#{#student.id}")//Sql查询
    @Query(value = "update Student set studentName = :#{#student.studentName} " +
            "where id = :#{#student.id}")//Hql查询
    void updateStudent(@Param("student") Student student);
}





